package com.xgggh.redpack.ui.redpack;

import android.os.Bundle;

import androidx.core.content.ContextCompat;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.DividerItemDecoration;

import com.xgggh.redpack.R;
import com.xgggh.redpack.base.ui.BaseActivity;
import com.xgggh.redpack.databinding.ActivityCategoryBinding;
import com.xgggh.redpack.domain.app.IntentFlag;
import com.xgggh.redpack.domain.category.Category;
import com.xgggh.redpack.domain.category.CategoryItem;
import com.xgggh.redpack.domain.redpack.RedPackType;
import com.xgggh.redpack.ui.redpack.viewbinder.CategoryViewBinder;

import me.drakeet.multitype.Items;
import me.drakeet.multitype.MultiTypeAdapter;

import static me.drakeet.multitype.MultiTypeAsserts.assertAllRegistered;
import static me.drakeet.multitype.MultiTypeAsserts.assertHasTheSameAdapter;

public class CategoryActivity extends BaseActivity {

    ActivityCategoryBinding mBinding;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         mBinding= DataBindingUtil. setContentView(this,R.layout.activity_category);
        setSupportActionBar(mBinding.toolbar.toolbar);

        mBinding.contentCategory.twinklingRefreshLayout.setPureScrollModeOn();
        //mBinding.contentCategory.recyclerView.setLayoutManager(new LinearLayoutManager(1,1));
        adapter.register(CategoryItem.class, new CategoryViewBinder());
        mBinding.contentCategory.recyclerView.setAdapter(adapter);

        DividerItemDecoration divider = new DividerItemDecoration(this,DividerItemDecoration.VERTICAL);
        divider.setDrawable(ContextCompat.getDrawable(this,R.drawable.divider));
        mBinding.contentCategory.recyclerView.addItemDecoration(divider);
        //免/战/码/筹/故事/接龙
        CategoryItem category0=new CategoryItem(RedPackType.mianfei,"免费红包","免费红包，立即领取",RedPackType.mianfei);
        CategoryItem category1=new CategoryItem(RedPackType.duizhan,"对战红包","战斗战斗，同台竞技",RedPackType.duizhan);
       // 激励红包--> 扫码红包
        CategoryItem category2=new CategoryItem(RedPackType.saoma,"扫码红包","立即扫码，惊喜大奖",RedPackType.saoma);
        CategoryItem category3=new CategoryItem(RedPackType.zhongchou,"众筹红包","众筹一个，随机瓜分",RedPackType.zhongchou);
        CategoryItem category4=new CategoryItem(RedPackType.gushi,"红包故事","你有故事，我有好酒",RedPackType.gushi);
        CategoryItem category5=new CategoryItem(RedPackType.jielong,"红包接龙","红包不断，欢乐无限",RedPackType.jielong);

        items.add(category0);
        items.add(category1);
        items.add(category2);
        items.add(category3);
        items.add(category4);
        items.add(category5);

        adapter.setItems(items);
        adapter.notifyDataSetChanged();

        /* 断言所有使用的类型都已注册 */
        assertAllRegistered(adapter, items);
        /* 断言 recyclerView 使用的是正确的 adapter */
        assertHasTheSameAdapter( mBinding.contentCategory.recyclerView, adapter);
    }



}
